package com.sxf.biz.coordinator.controller;

import com.sxf.biz.coordinator.service.CoordinatorService;
import com.sxf.biz.coordinator.vo.*;
import com.sxf.biz.customer.vo.SubjectsListRes;
import com.sxf.common.param.ResultInfo;
import com.sxf.core.db.page.Pagination;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: TODO
 * @Author Leo
 * @date 2024/3/1820:22
 */
@RestController
@Api(value = "临床填报端相关", tags = { "临床填报端相关" })
@Validated
@RequestMapping("/co")
public class CoordinatorController {

    @Autowired
    CoordinatorService coordinatorService;

    @ApiOperation(value = "项目列表", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/getByPage")
    public ResultInfo<Pagination<CoorProjectListRes>> getProjectByPage(@Validated @RequestBody CoordinatorBaseReq req){
        return ResultInfo.success(coordinatorService.getProjectByPage(req));
    }

    @ApiOperation(value = "项目详情", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/getDetail")
    public ResultInfo<CoorProjectDetailRes> getProjectDetail(@Validated @RequestBody CoorProjectDetailReq req){
        return ResultInfo.success(coordinatorService.getProjectDetail(req));
    }

    @ApiOperation(value = "协调人员加入的中心列表", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/getCenters")
    public ResultInfo<CoorCenterListRes> getProjectCenters(@Validated @RequestBody CoorProjectDetailReq req){
        return ResultInfo.success(coordinatorService.getProjectBindedCenters(req));
    }

    @ApiOperation(value = "协调人员加入的中心列表下受试者列表", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/getSubjectsByPage")
    public ResultInfo<Pagination<SubjectsListRes>> getSubjectListBind2Center(@Validated @RequestBody CoorSubjectListReq req){
        return ResultInfo.success(coordinatorService.getSubjectListBind2Center(req));
    }

    @ApiOperation(value = "协调人员添加受试者", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/addSubjects")
    public ResultInfo<AddSubjectsRes> addSubjects2Center(@Validated @RequestBody AddSubjectsReq req){
        return ResultInfo.success(coordinatorService.addSubject2Center(req));
    }

    @ApiOperation(value = "绑定受试者支付用户", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/bindSubjects")
    public ResultInfo<Boolean> bindSubjects(@Validated @RequestBody BindSubjectsReq req){
        return ResultInfo.success(coordinatorService.bindSubjects(req));
    }

    @ApiOperation(value = "修改受试者", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/editSubjects")
    public ResultInfo<Boolean> editSubjects(@Validated @RequestBody CoorEditSubjectsReq req){
        return ResultInfo.success(coordinatorService.editSubjects(req));
    }

    @ApiOperation(value = "重新绑定受试者", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/rebindSubjects")
    public ResultInfo<Boolean> rebindSubjects(@Validated @RequestBody BindSubjectsReq req){
        return ResultInfo.success(coordinatorService.rebindSubjects(req));
    }

    @ApiOperation(value = "退出", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/quit")
    public ResultInfo<Boolean> quit(@Validated @RequestBody CoorProjectSubjectsDetaiReq req){
        return ResultInfo.success(coordinatorService.quitProject(req));
    }

    @ApiOperation(value = "协调员/审核员--中心所有结算单申请列表", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/settle/getByPage")
    public ResultInfo<Pagination<CoorSettleListRes>> getSettleByPage(@Validated @RequestBody CoorSettleListReq req){
        return ResultInfo.success(coordinatorService.getSettleListByPage(req));
    }

    @ApiOperation(value = "结算单详情", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/settle/getDetail")
    public ResultInfo<CoorSettleDetailRes> getSettleDetail(@Validated @RequestBody CoorSettleDetailReq req){
        return ResultInfo.success(coordinatorService.getSettleDetail(req));
    }

    @ApiOperation(value = "添加结算单", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/settle/add")
    public ResultInfo<Boolean> addSettle(@Validated @RequestBody CoorAddSettleReq req){
        return ResultInfo.success(coordinatorService.addSettle(req));
    }

    @ApiOperation(value = "结算单审批通过", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/settle/approve")
    public ResultInfo<Boolean> approveSettle(@Validated @RequestBody CoorSettleDetailReq req){
        return ResultInfo.success(coordinatorService.approveSettle(req));
    }

    @ApiOperation(value = "结算单审批驳回", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/settle/reject")
    public ResultInfo<Boolean> rejectSettle(@Validated @RequestBody CoorRejectSettleReq req){
        return ResultInfo.success(coordinatorService.rejectSettle(req));
    }

    @ApiOperation(value = "修改结算单", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/settle/edit")
    public ResultInfo<Boolean> editSettle(@Validated @RequestBody CoorEditSettleReq req){
        return ResultInfo.success(coordinatorService.editSettle(req));
    }

    @ApiOperation(value = "删除未审批结算单", produces = "application/json", httpMethod = "POST")
    @PostMapping("/project/settle/delete")
    public ResultInfo<Boolean> deleteSettle(@Validated @RequestBody CoorSettleDetailReq req){
        return ResultInfo.success(coordinatorService.deleteSettle(req));
    }

    @ApiOperation(value = "协调员修改个人用户信息", produces = "application/json", httpMethod = "POST")
    @PostMapping("/updateUserInfo")
    public ResultInfo<Boolean> updateUserInfo(@Validated @RequestBody CoorUpdateUserInfoReq req){
        return ResultInfo.success(coordinatorService.updateCoorUserInfo(req));
    }



}
